<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/coupons.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body>
<div id="main"></div>
</body>
<script>
	zy_init();
	function jump(id){
		localStorage['coupons_id']=id;
		uexWindow.open('coupons_show','0','coupons_show.html','2','', '',0);
	}
	var page=1;
	function getMain(t){
		if (t==-1){
			$$('main').className="loading";
		}
		if(t<1){
			page=1;
		}
		var url = app_path+'index.php?m=iappCoupons&c=app&a=lists&catid='+catid_cur('coupons')+'&order='+filter_order_pro('coupons')+'&page='+page;
		//alert(url);
		uexXmlHttpMgr.open(t,'post',url,"8000");
		uexXmlHttpMgr.send(t);
	}
	window.uexOnload=function(type){
		if (!type){
			//uexWindow.evaluateScript('',0,"$$('content').className='';");
			uexWindow.setBounce("1");
			uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
			uexWindow.setBounceParams("1",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"","pullToReloadText":"上拉加载更多","releaseToReloadText":"释放加载","loadingText":"加载中，请稍等"}');
			uexWindow.showBounceView("0","#f3f3f3","1");
			uexWindow.notifyBounceEvent("0","1");
		    uexWindow.showBounceView("1","#f3f3f3","1");
　　　　	    uexWindow.notifyBounceEvent("1","1");
			uexWindow.onBounceStateChange=function(t,s){
　　　　　　		if(t=="0"||t=="1"){//下方弹动时
　　　　　　　　		if(s=="2"){//松开手指时
						getMain(t);
					}
　　　　　　		}
			}
			uexXmlHttpMgr.onData = function(opId, status, data){
				if(status==1){
					uexXmlHttpMgr.close(opId);
					uexWindow.resetBounceView(opId);
					data = JSON.parse(data);				
					if(opId<1){					
						$$('main').innerHTML='';
						uexWindow.setBounceParams("0",'{"imagePath":"res://loading.png","textColor":"#666","levelText":"上次更新：'+Now()+'","pullToReloadText":"拖动刷新","releaseToReloadText":"释放刷新","loadingText":"加载中，请稍等"}');
					}
					var list=data['list'];
					if(list.length>0){
						page++;
						$$("main").className = '';
						for (i = 0; i < list.length; i++) {
							
							var Div = document.createElement("div");
							Div.className='list';
							Div.setAttribute("onclick", "javascript:jump("+list[i]['id']+");");          
	                        var sd=new Date(list[i]['startdate']*1000);
							var ed=new Date(list[i]['enddate']*1000);
							Div.innerHTML = '<h3>'+list[i]['title']+'</h3><div class="loadimg"><img src="'+list[i]['picurl']+'" class="hide" onload="this.className=\'\'" /></div><p>'+list[i]['name']+'<br/><span>有效期：'+sd.getFullYear()+'-'+(sd.getMonth()+1)+'-'+sd.getDate()+' 至 '+ed.getFullYear()+'-'+(ed.getMonth()+1)+'-'+ed.getDate()+'</span></p>';
							$$('main').appendChild(Div);							
						}						
					}else{
						if(opId==-1||opId==0){
							$$("main").className = 'notdata';
						}
					}
				}else if(status ==-1) {//加载失败
					uexXmlHttpMgr.close(opId);
					if(opId==-1){
						$$("main").className='errer';
					}else{
						uexWindow.resetBounceView(opId);
						uexWindow.toast("0","5",'加载失败',1000);
					}
				}
			}
			
			getMain(-1);
		}
	}
	</script>
</html>